package com.diandiansong.manager.ui.biz;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.diandiansong.app.R;
import com.diandiansong.manager.utils.M;

import diandiansong.library.ui.base.BaseAct;
import diandiansong.library.utils.BaseEntity;
import diandiansong.library.utils.CCallBack;

/**
 * 添加团队成员
 */
public class TeamAddMember extends BaseAct {

    public static void start(Context context) {
        Intent starter = new Intent(context, TeamAddMember.class);
        context.startActivity(starter);
    }

    @butterknife.BindView(R.id.et_user_account)
    EditText mEtUserAccount;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addContentView(R.layout.manager_team_add);
        hideTitle();
    }

    @butterknife.OnClick({R.id.do_submit, R.id.do_finish})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.do_submit:
                String account = getText(mEtUserAccount);
                M.salesTeamAddinfo(account, new CCallBack<BaseEntity>() {
                    @Override
                    public void onSuccess(BaseEntity baseEntity) throws Exception {
                        Team.SubFragment.doRefresh();
                        finish();
                    }

                    @Override
                    public void onFailure(int code, String msg) {
                        toast(msg);
                    }
                });
                break;
            case R.id.do_finish:
                finish();
                break;
        }
    }
}
